package com.sailing.comm;

import java.util.Calendar;
import java.util.Date;

/**
 * Created by Guo Mengjia on 2017/7/3.
 */
public class CommonUtil {

    public static Date getWeekStartDate(){
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        Date date = cal.getTime();
        return date;
    }

    /**
     * 空对象判断
     * @param obj
     * @return
     */
    public static boolean isNullObject(Object obj){
        boolean result= false;
        if(null==obj||"".equals(obj)){
            result = true;
        }
        return  result;
    }

    /**
     * String可否转int
     * @param str
     * @return
     */
    public static boolean isCanParseInt(String str){
        if(str == null){//非空验证
            return false;
        }
        return str.matches("\\d+");//正则表达式判断该字串值是否为数字
    }

    public static boolean isFirstValueBigger(String objOne, String objTwo){
        if(isCanParseInt(objOne) && isCanParseInt(objTwo)){
            return Integer.parseInt(objOne) > Integer.parseInt(objTwo)? true:false;
        }else {
            return false;
        }
    }

    public static boolean isFirstValueBigger(int objOne, int objTwo){
        return objOne > objTwo? true:false;
    }


}
